package com.future.hedongjun.home.bean.response;

import com.future.baselib.entity.BaseResponse;
import com.future.hedongjun.home.bean.ClassCoursewareBean;
import com.future.hedongjun.home.bean.ClassHourBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Date：2018/12/6 14:27
 * author: liu.p.f
 * Describe：
 */
public class ClassCoursewareResponse extends BaseResponse {
    public List<ClassCoursewareBean> data;

    @Override
    public void parseInfo(String content) throws JSONException {
        JSONObject array = new JSONObject(content);
        String classId = array.getString("id");
        String className = array.getString("name");
        String buy_status = array.optString("buy_status");
        String classLogo = array.getString("logo_img");
        JSONArray jsonArray = array.getJSONArray("courseware");
        data = new ArrayList<>();
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject object = jsonArray.optJSONObject(i);
            ClassCoursewareBean bean = new ClassCoursewareBean();
            bean.courseName = object.optString("name");
            bean.courseUrl = object.optString("url");
            bean.buy_status = buy_status;
            bean.ClassName = className;
            bean.classId = classId;
            bean.classLogo = classLogo;
            data.add(bean);
        }
    }
}
